package org.airline.service;

import java.util.List;

import javax.annotation.Resource;

import org.airline.dao.INoticeDao;
import org.airline.entity.Notice;
import org.airline.entity.PageBean;
import org.springframework.stereotype.Component;
@Component("NoticeService")
public class NoticeService implements INoticeDao {

	private INoticeDao iNoticeDao;
	
	//删除公告
	@Override
	public void deleteNotice(int id) throws Exception {
		iNoticeDao.deleteNotice(id);
	}

	// 查询所有公告
	@Override
	public List<Notice> getAllNotice() throws Exception {
		return iNoticeDao.getAllNotice();
	}

	// 根据发布时间查询公告
	@Override
	public List<Notice> getNoticeByDate() throws Exception {
		return iNoticeDao.getNoticeByDate();
	}

	// 分页查询
	@Override
	public PageBean queryForPage(int pageSize, int page) throws Exception {
		return iNoticeDao.queryForPage(pageSize, page);
	}

	// 添加公告信息
	@Override
	public void saveNotice(Notice notice) throws Exception {
		iNoticeDao.saveNotice(notice);
	}

	// 更新公告
	@Override
	public void updateNotice(Notice notice) throws Exception {
		iNoticeDao.updateNotice(notice);
	}

	public INoticeDao getiNoticeDao() {
		return iNoticeDao;
	}

	@Resource(name = "NoticeDaoImpl")
	public void setiNoticeDao(INoticeDao iNoticeDao) {
		this.iNoticeDao = iNoticeDao;
	}

	// 根据ID查询公告
	@Override
	public Notice getNoticeById(int id) throws Exception {
		return iNoticeDao.getNoticeById(id);
	}

	@Override
	public PageBean queryForPageByKeyWords(String keyWord, int pageSize,
			int page) throws Exception {
		return iNoticeDao.queryForPageByKeyWords(keyWord, pageSize, page);
	}

}
